package client;


import interfaces.TaskI;
import interfaces.WorkerI;

import java.util.concurrent.Callable;

/**
 * Execute the Task
 *
 * @author tobias
 *
 * @param <IN>
 * @param <OUT>
 */
public class Worker<IN, OUT> implements WorkerI<IN, OUT>{
	IN dataIN = null;
	TaskI<IN, OUT> task = null;
	OUT dataOut=null;
	public Worker(IN data,TaskI t){
		task=t;
		dataIN=data;
	}

//	@Override
//	public OUT call() throws Exception {
//		excute();
//		return dataOut;
//	
//
//	}

	public void excute() throws Exception {
		dataOut = task.process(dataIN);
		//System.out.println("Client:"+dataOut);
		
	}


	/**
	 * set the new task
	 * @param task
	 */
	public void setTask(TaskI<IN, OUT> task) {
		this.task = task;
	}

	/**
	 * return the Result
	 * @return <OUT> data
	 */
	public OUT getDataOut() {
		return dataOut;
	}


}
